<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns="http://www.w3.org/1999/XSL/Format"
  xmlns:v="livcos.org/ns/view"
  exclude-result-prefixes="doc v">

  <xsl:template match="doc:chapter">
  	<v:chapter id="{@id}">
  		<v:title>
  			<xsl:apply-templates select="doc:title/node()"/>
  		</v:title>
  		<xsl:apply-templates select="* except doc:title"/>
  	</v:chapter>
  </xsl:template>

  <xsl:template match="doc:paragraph">
    <block margin-left="6mm" margin-top="4pt" margin-right="4mm" margin-bottom="4pt">
      <xsl:apply-templates select="node()"/>
    </block>
  </xsl:template>

  <xsl:template match="doc:subject">
    <block margin-left="6mm" margin-top="4pt" margin-right="4mm" margin-bottom="2pt">
      <xsl:if test="position() = 1">
        <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
      </xsl:if>
      <xsl:apply-templates select="doc:title/node()"/>
    </block>
    <block margin-left="8mm" margin-top="2pt" margin-right="4mm" margin-bottom="4pt"
      keep-together.within-page="always" font-size="9pt">
      <xsl:apply-templates select="doc:content/node()"/>
    </block>
  </xsl:template>

</xsl:stylesheet>
